//
//  HTWayBillOnVC.m
//  TruckUser
//
//  Created by Ting Han on 2017/10/18.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTWayBillOnVC.h"
#import "UIImageView+WebCache.h"
#import "HTCancleWayBillView.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <MAMapKit/MAMapKit.h>
#import <AMapSearchKit/AMapSearchKit.h>

#import "HTMyAnnotation.h"
#import "HTMyAnnotationView.h"
#import "HTAnnotationModel.h"

#import "UIView+Layout.h"
#import "HTCommentShowView.h"
#import "HTCommentView.h"

#import "HTDriverLocationVC.h"

@interface HTWayBillOnVC ()<MAMapViewDelegate,AMapSearchDelegate,HTCommentViewDelegate,HTCancleWayBillViewDelegate>
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollHeight;
//头部
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detialTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderIdLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *locationLabel;

//地图部分
@property (weak, nonatomic) IBOutlet UIView *mapViewArea;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *mapViewHeight;
@property (weak, nonatomic) IBOutlet UIView *locationViewArea;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *locationViewHeight;
@property (weak, nonatomic) IBOutlet MAMapView *mapView;
@property (weak, nonatomic) IBOutlet UIImageView *userHeadImageView;
@property (weak, nonatomic) IBOutlet UILabel *driverNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *caridLabel;
@property (weak, nonatomic) IBOutlet UILabel *truckLengthLabel;
@property (weak, nonatomic) IBOutlet UILabel *truckTypeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *carNumberImageView;
@property (weak, nonatomic) IBOutlet UILabel *carNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *startLabel;
@property (weak, nonatomic) IBOutlet UILabel *endLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodsTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *remarkLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIButton *bottomButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomSafeHeight;
//评论
@property (weak, nonatomic) IBOutlet UIView *commentViewArea;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *commentViewHeight;
@property (weak, nonatomic) IBOutlet UIImageView *commentImageView;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@property (weak, nonatomic) IBOutlet UIView *commentBottomView;


@property (nonatomic,strong) UIBarButtonItem *rightBarButton;
@property (nonatomic,strong)HTWayBillDetialModel *wayBillDetialModel;

@property (nonatomic,strong) AMapSearchAPI *search;

@end

@implementation HTWayBillOnVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"运单详情";
    [self setupNav];
    [self initData];
    self.userHeadImageView.layer.masksToBounds = YES;
    self.userHeadImageView.layer.cornerRadius = 21.5;
}
- (void)initData{
    self.bottomSafeHeight.constant = IPHONE_SAFEBOTTOMAREA_HEIGHT;
    [self setWayBillTypeWith:self.wayBillType];
    [self netLoadData];
    _mapView.mapType = MAMapTypeStandard;
    _mapView.mapType = MAMapTypeStandard;
    // 设置成NO表示关闭指南针；YES表示显示指南针
    _mapView.showsCompass= NO;
    //设置成NO表示不显示比例尺；YES表示显示比例尺
    _mapView.showsScale= NO;
    [_mapView setZoomLevel:16.1 animated:YES];
    self.mapView.delegate = self;
    self.search = [[AMapSearchAPI alloc]init];
    self.search.delegate = self;
}
- (IBAction)callPhoneButton:(id)sender {
    if (self.wayBillDetialModel == nil || self.wayBillDetialModel.phones == nil ||self.wayBillDetialModel.phones.length <= 0) {
        [HTShowUtil showMessage:@"运单详情获取失败"];
        return;
    }
    NSString *phone = self.wayBillDetialModel.phones;
    NSString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phone];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    
}
- (void)setupNav{
    self.rightBarButton = [[UIBarButtonItem alloc]initWithTitle:@"取消交易" style:UIBarButtonItemStyleDone target:self action:@selector(didCancleWaybill)];
    self.navigationItem.rightBarButtonItem = self.rightBarButton;
    
}
- (IBAction)bottomButtonAction:(id)sender {
    if (self.wayBillDetialModel == nil) {
        [HTShowUtil showMessage:@"运单详情获取失败"];
        return;
    }
    switch ([self.wayBillDetialModel.state integerValue]) {
        case 0://待接单-->确认接单
        {
            [UIAlertController alertStyleShowInController:self title:@"温馨提示" message:@"确定接单吗？" alertActionsBlock:^(NSMutableArray<UIAlertAction *> *alertActions) {
                [alertActions addObject:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
                [alertActions addObject:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    [self netLoadConformReceiveOrder];
                }]];
            } completion:nil];
        }
            break;
        case 1://运输中-->确定到货
        {
            [UIAlertController alertStyleShowInController:self title:@"温馨提示" message:@"确定到货吗？" alertActionsBlock:^(NSMutableArray<UIAlertAction *> *alertActions) {
                [alertActions addObject:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
                [alertActions addObject:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    [self netLoadConformReceive];
                }]];
            } completion:nil];
        }
            break;
        case 2://到货-->评价
        {
            HTCommentView *commentView = [[HTCommentView alloc]init];
            commentView.delegate = self;
            [commentView showView];
            
        }
            break;
        case 4:
        {
            
        }
            break;
        default:
            break;
    }
    
    
}
- (void)didCancleWaybill{
    if (self.wayBillDetialModel == nil) {
        [HTShowUtil showMessage:@"运单详情获取失败"];
        return;
    }
    HTCancleWayBillView *can = [[HTCancleWayBillView alloc]init];
    [can setupPhone:self.wayBillDetialModel.phones];
    [can setupCarid:self.wayBillDetialModel.carnumber];
    [can setupName:self.wayBillDetialModel.dirvername];
    [can setupHeadImage:self.wayBillDetialModel.driverpic];
    can.delegate = self;
    [can showView];
}
- (void)didCommitWithReason:(NSString *)reason cacleWaybill:(HTCancleWayBillView *)cancleView{
    
    [self netLoadCancleOrderContent:reason cacleWaybill:(HTCancleWayBillView *)cancleView];
    
}
#pragma mark -- 地图
- (IBAction)checkLocation:(id)sender {
    if (self.wayBillDetialModel == nil || self.wayBillDetialModel.carid == nil) {
        return;
    }
    HTDriverLocationVC *location = [[HTDriverLocationVC alloc]init];
    location.carid = self.wayBillDetialModel.carid;
    [self.navigationController pushViewController:location animated:YES];
}
//获取位置
- (void)addressMap{
    AMapReGeocodeSearchRequest *geo = [[AMapReGeocodeSearchRequest alloc] init];
    AMapGeoPoint *point =  [[AMapGeoPoint alloc]init];
    point.latitude = [_wayBillDetialModel.lat doubleValue];
    point.longitude = [_wayBillDetialModel.lng doubleValue];
    geo.location = point;
   [self.search AMapReGoecodeSearch:geo];
}
//添加气泡
- (void)addAnotationView{
    if (self.wayBillDetialModel.lat == nil || self.wayBillDetialModel.lat.length <= 0 || self.wayBillDetialModel.lng == nil || self.wayBillDetialModel.lng.length <= 0) {
        return;
    }
    HTMyAnnotation *item = [[HTMyAnnotation alloc]init];
    item.coordinate = CLLocationCoordinate2DMake((CLLocationDegrees)[self.wayBillDetialModel.lat doubleValue], (CLLocationDegrees)[ self.wayBillDetialModel.lng doubleValue]);
    item.state = _wayBillDetialModel.state;
    [self.mapView addAnnotation:item];
    [self.mapView setCenterCoordinate:item.coordinate animated:YES];
}
- (void)mapView:(MAMapView *)mapView mapDidZoomByUser:(BOOL)wasUserAction{
    
}
- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view{
    view.selected = NO;
}
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation{
    if ([annotation isKindOfClass:[HTMyAnnotation class]]) {
        MAAnnotationView *view = [(HTMyAnnotation *)annotation getAnnotationView:mapView];
        return view;
    }
    return nil;
}
- (void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest *)request response:(AMapReGeocodeSearchResponse *)response{
    if (response.regeocode == nil)
    {
        return;
    }
    self.locationLabel.text = response.regeocode.formattedAddress;
}
- (void)onGeocodeSearchDone:(AMapGeocodeSearchRequest *)request response:(AMapGeocodeSearchResponse *)response{
    if (response.geocodes.count == 0)
    {
        return;
    }
    AMapGeoPoint *point = response.geocodes[0].location;
    [self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(point.latitude, point.longitude) animated:YES];
}

#pragma mark --- 网络请求
//运单详情
- (void)netLoadData{
    [self startHud];
    [HTHttpRequestManager requestWaybillDetialWithOrderid:self.wayBillModel.ID success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"运单详情：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"运单详情获取失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        self.wayBillDetialModel = [HTWayBillDetialModel mj_objectWithKeyValues:responseObject[@"data"]];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
        [HTShowUtil showMessage:@"运单详情获取失败"];
    }];
}

//确认收货
- (void)netLoadConformReceive{
    [self startHud];
    [HTHttpRequestManager requestWaybillComformReceivedWithId:self.wayBillModel.ID success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"确认收货：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"确认收货失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        [HTShowUtil showMessage:responseObject[@"message"]];
        [self netLoadData];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
        [HTShowUtil showMessage:@"确认收货失败"];
    }];
}

//确认接收订单
- (void)netLoadConformReceiveOrder{
    [self startHud];
    [HTHttpRequestManager requestWaybillComformWithOrderid:self.wayBillModel.ID success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"确认接单：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"确认接单失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        [HTShowUtil showMessage:responseObject[@"message"]];
         [self netLoadData];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
        [HTShowUtil showMessage:@"确认接单失败"];
    }];
}
//取消订单
- (void)netLoadCancleOrderContent:(NSString *)content cacleWaybill:(HTCancleWayBillView *)cancleView{
    YDHUD *hud = [YDHUD juhuaHUD];
    [[UIApplication sharedApplication].keyWindow addSubview:hud];
    [hud showAnimated:YES];
    [HTHttpRequestManager requestWaybillCancleWithOrderid:self.wayBillDetialModel.ID contenid:content success:^(id  _Nullable responseObject) {
        [hud hideAnimated:YES];
        DBLog(@"取消订单：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"取消订单失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        [HTShowUtil showMessage:responseObject[@"message"]];
         [self netLoadData];
        [cancleView dismissView];
    } failure:^(NSError * _Nonnull error) {
        [hud hideAnimated:YES];
         [HTShowUtil showMessage:@"取消订单失败"];
    }];
    
}
- (void)didCommitComment:(NSString *)message scroll:(NSString *)scroll commentView:(HTCommentView *)commentView{
    [self startHud];
    [HTHttpRequestManager requestWaybillCommentWithOrderid:self.wayBillModel.ID scroller:scroll impersson:message success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"评价：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"评价失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        [HTShowUtil showMessage:responseObject[@"message"]];
        [commentView dismissView];
        [self netLoadData];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
        [HTShowUtil showMessage:@"评价失败"];
    }];
}

#pragma mark --- 几个状态设置
- (void)setWayBillTypeWith:(WayBillDetialType)wayBillType{
    switch (wayBillType) {
        case WayBillDetialTypeReceive://未接单
        {
            //title部分
            self.navigationItem.rightBarButtonItem = self.rightBarButton;
            self.titleLabel.text = @"运单状态：待接单";
            self.detialTitleLabel.text = @"司机已承运，请确认接单";
            //评价部分
            self.commentViewArea.hidden = YES;
            self.commentViewHeight.constant = 1;
            //按钮部分
            self.bottomView.hidden = NO;
            self.bottomHeight.constant = kWidth(55);
            [self.bottomButton setTitle:@"确认接单" forState:UIControlStateNormal];
            
            //地图部分
            self.mapViewArea.hidden = NO;
            self.locationViewHeight.constant = kWidth(40);
            self.mapViewHeight.constant = kWidth(168);
            
            
        }
            break;
        case WayBillDetialTypeOnRunning://运输中
        {
            //title部分
            self.navigationItem.rightBarButtonItem = self.rightBarButton;
            self.titleLabel.text = @"运单状态：运输中";
            self.detialTitleLabel.text = @"请在货物到达之后点击确认到货";
            //评价部分
            self.commentViewArea.hidden = YES;
            self.commentViewHeight.constant = 1;
            //按钮部分
            self.bottomView.hidden = NO;
            self.bottomHeight.constant = kWidth(55);
            [self.bottomButton setTitle:@"确认到货" forState:UIControlStateNormal];
            //地图部分
            self.mapViewArea.hidden = NO;
            self.locationViewHeight.constant = kWidth(40);
            self.mapViewHeight.constant = kWidth(168);
            
        }
            break;
        case WayBillDetialTypeComment://待评价
        {
            //title部分
            self.navigationItem.rightBarButtonItem = nil;
            self.titleLabel.text = @"运单状态：待评价";
            self.detialTitleLabel.text = @"运输已完成，请评价司机";
            //评价部分
            self.commentViewArea.hidden = YES;
            self.commentViewHeight.constant = 1;
            //按钮部分
            self.bottomView.hidden = NO;
            self.bottomHeight.constant = kWidth(55);
            [self.bottomButton setTitle:@"评价司机" forState:UIControlStateNormal];
            //地图部分
            self.locationViewHeight.constant = kWidth(1);
            self.mapViewHeight.constant = kWidth(1);
            for (UIView *view in self.mapViewArea.subviews) {
                [view removeFromSuperview];
            }
            self.mapViewArea.hidden = YES;
            
        }
            break;
        case WayBillDetialTypeOver://已完成
        {
            //title部分
            self.navigationItem.rightBarButtonItem = nil;
            self.titleLabel.text = @"运单状态：已完成";
            self.detialTitleLabel.text = @"交易已完成，欢迎再次使用本平台担保交易";
            //评价部分
            self.commentViewArea.hidden = NO;
            self.commentViewHeight.constant = 100;
            //按钮部分
            self.bottomView.hidden = YES;
            self.bottomHeight.constant = kWidth(1);
            //地图部分
            self.locationViewHeight.constant = kWidth(1);
            self.mapViewHeight.constant = kWidth(1);
            for (UIView *view in self.mapViewArea.subviews) {
                [view removeFromSuperview];
            }
            self.mapViewArea.hidden = YES;
        }
            break;
        case WayBillDetialTypeCancle://已取消
        {
            //title部分
            self.navigationItem.rightBarButtonItem = nil;
            self.titleLabel.text = @"运单状态：已取消";
            self.detialTitleLabel.text = @"交易已完成，欢迎再次使用本平台担保交易";
            //评价部分
            self.commentViewArea.hidden = YES;
            self.commentViewHeight.constant = 1;
            //按钮部分
            self.bottomView.hidden = YES;
            self.bottomHeight.constant = kWidth(1);
            //地图部分
            self.locationViewHeight.constant = kWidth(1);
            self.mapViewHeight.constant = kWidth(1);
            for (UIView *view in self.mapViewArea.subviews) {
                [view removeFromSuperview];
            }
            self.mapViewArea.hidden = YES;
        }
            break;
            
        default:
            break;
    }
    if (self.commentViewArea.bottom > self.bottomView.top) {
        self.scrollHeight.constant = self.commentViewArea.bottom + 20;
    }else{
        self.scrollHeight.constant =  self.bottomView.top + 20;
    }
    [self.view setNeedsLayout];
}

- (void)setWayBillDetialModel:(HTWayBillDetialModel *)wayBillDetialModel{
    _wayBillDetialModel = wayBillDetialModel;
    self.wayBillType = [wayBillDetialModel.state integerValue];
    [self setWayBillTypeWith:_wayBillType];
    self.orderIdLabel.text = wayBillDetialModel.orderid;
    self.timeLabel.text = [HTUtils timeIntervalExchange:wayBillDetialModel.createtime];
    if ([wayBillDetialModel.state isEqualToString:@"0"] || [wayBillDetialModel.state isEqualToString:@"1"]) {
        [self addAnotationView];
       // [self addressMap];
        self.locationLabel.text =  [NSString stringWithFormat:@"当前位置：%@",wayBillDetialModel.address];
        if (wayBillDetialModel.address == nil || wayBillDetialModel.address.length <= 0) {
            self.locationLabel.text = @"当前位置：暂无定位";
        }
    }
    [self.userHeadImageView sd_setImageWithURL:[NSURL URLWithString:wayBillDetialModel.driverpic] placeholderImage:[UIImage imageNamed:@"bg_headsculpture"]options:SDWebImageRefreshCached];
    self.driverNameLabel.text = wayBillDetialModel.dirvername;
    NSString *carid = wayBillDetialModel.carnumber;
    if (wayBillDetialModel.carnumber != nil || wayBillDetialModel.carnumber.length > 2) {
        carid = [carid stringByReplacingCharactersInRange:NSMakeRange(2, 0) withString:@"·"];
    }
    self.carNumberLabel.text = carid;
    if ([wayBillDetialModel.numbertype isEqualToString:@"1"]) {//blue
        self.carNumberImageView.image = [UIImage imageNamed:@"bg_license_blue"];
    }else{//2 yellow
        self.carNumberImageView.image = [UIImage imageNamed:@"bg_license_yellow"];
    }
    self.phoneLabel.text = wayBillDetialModel.phones;
    self.caridLabel.text = wayBillDetialModel.driverid;
    self.truckLengthLabel.text = [NSString stringWithFormat:@"%@米",wayBillDetialModel.carlength];;
    self.truckTypeLabel.text = wayBillDetialModel.cartypes;
    self.startLabel.text = wayBillDetialModel.from;
    self.endLabel.text = wayBillDetialModel.toadd;
    NSString *length = [HTUtils sortLengthDisplayStringWith:wayBillDetialModel.length];
    NSString *type = @"不限车型";
    if (!(wayBillDetialModel.types == nil || wayBillDetialModel.types.length <= 0)) {
        type = wayBillDetialModel.types;
    }
    NSString *dun = @"";
    if ([wayBillDetialModel.unti isEqualToString:@"1"]) {
        dun =[NSString stringWithFormat:@"%@吨",wayBillDetialModel.weight];
    }else{
        dun =[NSString stringWithFormat:@"%@方",wayBillDetialModel.weight];
    }
    NSString *cartype = @"";
    if (!(wayBillDetialModel.cartype == nil || wayBillDetialModel.cartype.length <= 0)) {
        cartype = wayBillDetialModel.cartype;
    }
    self.goodsTypeLabel.text = [NSString stringWithFormat:@"%@ %@ / %@ %@ / 运费%@元",length,type,dun,cartype, wayBillDetialModel.pricer];
    self.remarkLabel.text = wayBillDetialModel.remark;
    if ([wayBillDetialModel.state isEqualToString:@"3"]) {//评论
        NSArray *array = [wayBillDetialModel.carimpress componentsSeparatedByString:@","];
        NSMutableArray  *viewArray = [NSMutableArray arrayWithCapacity:3];
        for (NSString *title in array) {
            if ([wayBillDetialModel.carscorell integerValue] == 3) {//好评
                
                HTCommentShowView *showView = [[HTCommentShowView alloc]initWithFrame:CGRectMake(self.commentImageView.left, self.commentImageView.bottom + 8, 100, 30) Title:title withHightComment:YES];
                [viewArray addObject:showView];
                [self.commentBottomView addSubview:showView];
            }else{
                HTCommentShowView *showView = [[HTCommentShowView alloc]initWithFrame:CGRectMake(self.commentImageView.left, self.commentImageView.bottom + 8, 100, 30) Title:title withHightComment:NO];
                [viewArray addObject:showView];
                [self.commentBottomView addSubview:showView];
            }
        }
        for (int i= 1; i< viewArray.count; i++) {
            HTCommentShowView *showViewLast = viewArray[i-1];
            HTCommentShowView *showView = viewArray[i];
            if (self.commentViewArea.right - showViewLast.right - 8 < showView.width) {
                showView.frame = CGRectMake(self.commentImageView.left, showViewLast.bottom + 8, showView.width, showView.height);
            }else{
                showView.frame = CGRectMake(showViewLast.right + 8, showViewLast.top, showView.width, showView.height);
            }
        }
        if (viewArray != nil && viewArray.count > 0) {
           self.commentViewHeight.constant = 30 + [(HTCommentShowView *)viewArray.lastObject bottom] + 20;
        }else{
            self.commentViewHeight.constant = 100;
        }
        if (self.commentViewArea.bottom > self.bottomView.top) {
            self.scrollHeight.constant = self.commentViewArea.bottom + 80;
        }else{
            self.scrollHeight.constant = self.bottomView.top;
        }
        switch ([wayBillDetialModel.carscorell integerValue]) {
            case 0:
            {
                self.commentLabel.text = @"未评价";
                self.commentImageView.image = [UIImage imageNamed:@"icon-highpraise-select"];
            }
                break;
            case 1://差评
                
            {
                self.commentLabel.text = @"差评";
                self.commentImageView.image = [UIImage imageNamed:@"icon-lowpraise-select"];
              
            }
                break;
            case 2://一般
            {
                self.commentLabel.text = @"一般";
                self.commentImageView.image = [UIImage imageNamed:@"icon-middlepraise-select"];
            }
                break;
            case 3://好评
            {
                self.commentLabel.text = @"好评";
                self.commentImageView.image = [UIImage imageNamed:@"icon-highpraise-select"];
            }
                break;
                
            default:
                break;
        }
    }
}
@end

@implementation HTWayBillDetialModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{
             @"ID":@"id"
             };
}

@end
